package com.elf.stepcounter;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

import com.elf.zero.app.AbsLinearLayout;
import com.elf.zero.step.StepData;
import com.elf.zero.step.StepManger;

public class StepDataListItem extends AbsLinearLayout {

    private TextView tv_date, tv_step, tv_km;

    public StepDataListItem(Context context) {
        super(context);
    }

    public StepDataListItem(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.list_item_step_data;
    }

    @Override
    protected void initView(AttributeSet attrs) {
        tv_date = findViewById(R.id.tv_date);
        tv_step = findViewById(R.id.tv_step);
        tv_km = findViewById(R.id.tv_km);
    }

    public void setData(StepData data) {
        tv_date.setText(data.date);
        tv_step.setText(String.valueOf(data.step));
        tv_km.setText(StepManger.stepToKm(data.step) + "公里");
    }
}
